//
//  PHAds.m
//  PhnixHome
//
//  Created by Levy Xu on 2018/1/10.
//  Copyright © 2018年 Levy Xu. All rights reserved.
//

#import "PHAds.h"

@implementation PHAds

@end

@implementation PHAdsManager

+(void)requestAds:(void(^)(NSArray *ads))finish {
    [[NetUtils JSONManager] POST:@"other/advertising.json" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        CommonResult *result = [CommonResult mj_objectWithKeyValues:[responseObject mj_JSONObject]];
        LOG(@"responseObject %@",responseObject);
        
        if (result.is_result_suc) {
            NSArray *ads = [PHAds mj_objectArrayWithKeyValuesArray:result.object_result];
            !finish ?: finish(ads);
        } else {
            !finish ?: finish(nil);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        !finish ?: finish(nil);
    }];
}

@end
